package com.yinquan.util;

import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

import com.yishun.springboot.dao.CWRServiceTest;

import lombok.extern.slf4j.Slf4j;

/**
 * 仿layui表格输出的...
 * 
 * 
 * @return
 * @exception public class teString{ }
 */

@Slf4j
public class demoPrintSQL {
	public static void main(String[] args) {
		demoPrintSQL dpq = new demoPrintSQL();
//		dpq.excep();

	}

	public void excep() {
		String pageHeader = "INSERT INTO t2layui (id,username,sex,city,sign,experience,logins,wealth,classify,score) VALUES (";

		String pageFooter = ");";
		// 该页头

		int id = 10000;
		int user = -1; // 因为for循环里面第一个也加1了，所以从-1开始。就能经过++后显示是第一个数字是0。以下int初始化为-1的同理
		String[] sex = new String[] { "女", "男" };
		Random random = new Random(); // 这个随机新建对象是对应上面那个
		int city = -1;
		int sign = 01;
		int[] experience = new int[100]; // 同下面数组的一样，因为layu总共的测试数据30条；所以数组长度是储存大小
		int[] logins = new int[100];
		int[] wealth = new int[100];
		String[] classify = new String[] { "毛线", "狗屌" };
		int[] score = new int[100];
		for (int i = 0; i <= 100; i++) {
//			log.info("id"+(++id));
			pageHeader = pageHeader + (++id) + ",";
//			log.info("user"+(++user));
			pageHeader = pageHeader + "\"" + "user-" + (user++) + "\"" + ","; // 引号里面也要双引,
																				// \"表示在最外面有双引号情况下表示里面仅仅一个的双引号，即,
																				// 然后要考虑的就是拼接用到的+号，有一个元素相隔就用+号连接。一个转义后的引号也要+号相隔，就像"\"代表的就只是",后面要加+
//			log.info("RandomSex:"+RandomStr(sex));   //String有参数，是传入的数组名称
			pageHeader = pageHeader + "\"" + RandomStr(sex) + "\"" + ",";
//			log.info("city"+(++city));
			pageHeader = pageHeader + "\"" + "城市-" + (++city) + "\"" + ",";
//			log.info("sign:"+RandomInt(220));//Int随机数有参数，该随机数产生的参数范围   该值是220内
			pageHeader = pageHeader + "\"" + "签名-" + RandomInt(100) + "\"" + ",";
//			log.info("experience:"+RandomInt(random));//Int随机数有参数，该随机数产生的参数范围
			pageHeader = pageHeader + RandomInt(220) + ",";
//			log.info("RandomLogins:"+RandomInt(random));//Int随机数有参数，该随机数产生的参数范围
			pageHeader = pageHeader + RandomInt(random) + ",";
//			log.info("RandomWealth:"+RandomInt(86545695));    //Int随机数有参数，该随机数产生的参数范围 该值是8位数字
			pageHeader = pageHeader + RandomInt(86545695) + ",";
//			log.info("RandomClassify:"+RandomStr(classify));
			pageHeader = pageHeader + "\"" + RandomStr(classify) + "\"" + ",";
//			log.info("RandomWealth:"+RandomInt(100));    //Int随机数有参数，该随机数产生的参数范围 该值是100内
			pageHeader = pageHeader + RandomInt(100);
			pageHeader += pageFooter; // 加页尾
			log.info(pageHeader);

			pageHeader = "INSERT INTO t2layui (id,username,sex,city,sign,experience,logins,wealth,classify,score) VALUES ("; // 重置sql以进行新一轮迭代

		}
	}

	// 上面的运行方法
	public static int RandomInt(Random random) {
		return random.nextInt(220);
	}

	public static int RandomInt(int ints) {
		return (int) (Math.random() * ints);
	}

	// 上面的运行方法
	public static String RandomStr(String[] strs) {
		int random_index = (int) (Math.random() * strs.length);
		return strs[random_index];
	}

}
